package com.example.async;

import com.example.service.PersonService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.concurrent.Future;

@Component
public class TaskPerson {
    private Logger logger = LoggerFactory.getLogger(TaskPerson.class);

    @Autowired
    private PersonService personService;


    @Async
    @Transactional(readOnly = true)
    public Future<Boolean> doTaskQuery(String id_num) throws Exception {
        Boolean result = personService.existsByIDNum(id_num);
        return new AsyncResult<Boolean>(result);
    }
}
